import { StockNodeLink, StockNodeLinkGateway, deleteStockNodeLinkDto, StockNodeLinkInterfaceWithGrant, DisableRes } from "qqlx-core";

import { StockNodeLinkSchema } from "@/river/ton-stock-node";
import { ViewBase, ViewBaseAction } from "@view/view-base";

export class ViewStockNodeLink extends ViewBase<StockNodeLink> implements ViewBaseAction<StockNodeLink>, StockNodeLinkInterfaceWithGrant<{}> {
  private static instance: ViewStockNodeLink;
  static getInstance(options?: { isSingleton?: boolean }) {
    if (options?.isSingleton === false) {
      return new ViewStockNodeLink();
    }

    if (!this.instance) this.instance = new ViewStockNodeLink();
    return this.instance;
  }

  private constructor() {
    super();
    this.initial();
    this.insertDefaultCondition();
  }

  getSchema(): StockNodeLink {
    return new StockNodeLinkSchema();
  }

  async delete(dto: deleteStockNodeLinkDto) {
    this.pending();
    const res = await this.$request.delete<deleteStockNodeLinkDto, DisableRes>(StockNodeLinkGateway.path, dto);
    return res;
  }
}
